LocalScript
LocalScripts run on the client side (player's computer). They are used for GUIs, camera control, player input, animations, and more.
local button = script.Parent
button.MouseButton1Click:Connect(function()
print("Button clicked!")
end)
local player = game.Players.LocalPlayer
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").WalkSpeed = 50
end)
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 120
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
print("E key pressed!")
end
end)
local tweenService = game:GetService("TweenService")
local ui = script.Parent
local tween = tweenService:Create(ui, TweenInfo.new(1), {Position = UDim2.new(0.5, 0, 0.5, 0)})
tween:Play()
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Move:Connect(function()
if mouse.Target then
print("Hovering on", mouse.Target.Name)
end
end)
local sound = script.Parent:WaitForChild("Sound")
sound:Play()
local textbox = script.Parent
textbox.FocusLost:Connect(function()
print("Typed:", textbox.Text)
end)
local frame = script.Parent:WaitForChild("MyFrame")
frame.Visible = false
wait(3)
frame.Visible = true
local label = script.Parent
local messages = {"Loading.", "Loading..", "Loading..."}
while true do
for _, msg in pairs(messages) do
label.Text = msg
wait(0.5)
end
end
📘 Tutorial